1 Imports System.Data.OleDb
2
3 Public Class frmLogin
4
5     Dim id_con As New OleDbConnection(
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=MainDB.accdb;")
6     Dim id_com As New OleDbCommand()
7
8     Public Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
9         CreateObject(
"WScript.Shell").Popup("Please Note : This is Demo Version ! this Software can get vanished after few days database may get destroy !
10 Contact us
for Original Software Licence.
11 Email ID : mayuri.infospace@gmail.com skype: DigitalMayu"
, 1, "Demo Software")
12         Try
13             If txtId.Text <>
"" And txtPass.Text <> "" And lstType.SelectedItem IsNot "" Then
14                 Dim id_read As OleDbDataReader
15                 id_con.Open()
16                 If lstType.SelectedItem =
"Admin" Then
17                     id_com = New OleDbCommand(
"Select * from Admin where Id ='" & txtId.Text & "'", id_con)
18                     id_read = id_com.ExecuteReader()
19                     If id_read.HasRows Then
20                         id_read.Read()
21                         If txtPass.Text = id_read(
5).ToString() And txtId.Text = "Admin" Then
22                             Me.Hide()
23                             frmAdmin.btnAddAdmin.Enabled = True
24                             frmAdmin.Show()
25                         ElseIf txtPass.Text = id_read(
5).ToString() And txtId.Text = id_read(0).ToString Then
26                             Me.Hide()
27                             frmAdmin.btnAddAdmin.Enabled = False
28                             frmAdmin.btnAdminDetails.Enabled = False
29                             frmAdmin.Show()
30                         Else
31                             MsgBox(
"Please enter correct Id or Password")
32                             Clearall()
33                         End If
34                     End If
35                 ElseIf lstType.SelectedItem =
"Student" Then
36                     id_com = New OleDbCommand(
"Select * from Student where RollNo =" & txtId.Text & "", id_con)
37                     id_read = id_com.ExecuteReader()
38                     If id_read.HasRows Then
39                         id_read.Read()
40                         If txtPass.Text = id_read(
2).ToString() Then
41                             Me.Hide()
42                             frmMainStudent.Show()
43                         Else
44                             MsgBox(
"Please enter correct Id or Password")
45                             Clearall()
46                         End If
47                     End If
48                 Else
49                     MsgBox(
"Please select login type", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "")
50                 End If
51             Else
52                 MsgBox(
"Fill in Id and password fields", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "")
53             End If
54         Catch ex As Exception
55             MsgBox(ex.Message)
56         Finally
57             id_con.Close()
58         End Try
59     End Sub
60
61     Public Sub Clearall()
62         txtId.Text =
""
63         txtPass.Text =
""
64     End Sub
65
66     Private Sub Clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
67         Clearall()
68     End Sub
69
70     Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
71         Me.Close()
72     End Sub
73 End Class


Gõ tìm kiếm nhanh...